package com.asiainfo.complier.ui;

import com.asiainfo.complier.helper.UIHelper;

import javax.swing.*;
import java.awt.*;

public class DefaultCellRenderer extends JLabel implements ListCellRenderer {
	/**
	 * DefaultCellRenderer
	 */
	private static final long serialVersionUID = -3796126434706674678L;

	private ImageIcon classIco;

	public DefaultCellRenderer() {
		setOpaque(true);
		classIco = UIHelper.getImageIco("com/asiainfo/images/archive.png");

	}

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		setIcon(classIco);
		setText(value.toString());
		if (isSelected) {
			setForeground(list.getSelectionForeground());
			setBackground(list.getSelectionBackground());
		} else {
			setForeground(list.getForeground());
			setBackground(list.getBackground());
		}
		return this;
	}
}
